<template>
    <div  v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" infinite-scroll-distance="10" class="sc">
        <ul class="list" v-if="1==isAccountEntry">
              <li v-for="(item,ind) in shouyi_data" :key="ind">
                <div class="list_right">
                  <h1><span v-if=" item.orderType>0">+</span><span v-else>-</span>{{item.userProfit |amountMin100(2)}}</h1>
                  <h1>{{item.ctime |formatDateTIME()}}</h1>
                </div>
                <div class="list_left">
                  <h1 v-if="-1==item.orderType || 31==item.orderType"  @click="href_mx(item.orderId)">
                    {{jsonOrderType[item.orderType] || "收益"}}
                    {{ 0 ==balanceType && (1== item.orderType || 7== item.orderType || 26==item.orderType) ? jsonProfitType[item.profitType] : ""}}
                  </h1>
                  <h1 v-else>
                    {{jsonOrderType[item.orderType] || "收益"}}
                    {{ 0 ==balanceType && (1== item.orderType || 7== item.orderType || 26==item.orderType) ? jsonProfitType[item.profitType] : ""}}
                  </h1>
                  <h1>余额:<span class="min_new">{{item.userBalance | amountMin100(2)}}</span></h1>
                </div>  
              </li>
            </ul>
             <ul class="list" v-else>
                <li v-for="(item,ind) in shouyi_data" :key="ind">
                    <div class="list_left list_leftH" v-if="item.orderType==-1 || item.orderType==31" @click="href_mx(item.orderId)">
                      <h1><span class="TiTlelef">{{jsonwayszm[item.profitType]}}</span>{{jsonway[item.profitType]}}</h1>
                    </div>
                    <div class="list_left list_leftH" v-else>
                      <h1 v-if="item.orderType==-1">{{jsonway[item.orderType]}}</h1>
                      <h1 v-else><span class="TiTlelef">{{jsonwayszm[item.profitType]}}</span>{{jsonway[item.profitType]}}</h1>
                    </div>
                    <div class="list_right">
                      <h1>{{item.userProfit |amountMin100(2)}}</h1>
                      <h1>{{item.ctime |formatDateTIME()}}</h1>
                    </div>
                 </li>
            </ul>
             <loadingtmp :busy="busy" :datalength="shouyi_data.length" :loadall="loadall"></loadingtmp>
    </div>
</template>
<script>
import loadingtmp from '@/components/load/loading'
export default {
     data () {
      return {
        balanceType: this.$route.query.balancetype || 0,
        shouyi_data:[
        ],
        page:1,
        pageSize:20,
        busy:false,
        loadall: false,
        jsonOrderType:{},
        jsonProfitType:{"1":'直推收益',"2":"间推收益","3":'平台奖励',"4":'平台奖励'},
        jsonBusOrderType:{"1":'线下店扫码付款奖励',"-1":"提现","31":"提现失败返款"},
        jsonPerOrderType:{"1":'线下店扫码付款奖励',"-1":"提现","31":"提现失败返款"},
        isAccountEntry:this.$route.query.isAccountEntry,
        jsonway:{"1":'直推收益',"2":"间推收益","3":'平台奖励',"4":'平台奖励',"-1":'现金提现',"31":'提现失败返款'},
        jsonwayszm:{"1":'直',"2":'间',"3":'平',"4":'平'},
      }},
      components: {
      loadingtmp
  },
  created(){
    if( 0 !=this.balanceType && 1!=this.balanceType){this.balanceType =0}
    this.jsonOrderType = 0== this.balanceType? this.jsonPerOrderType: this.jsonBusOrderType;
  },
    mounted(){

    },
    methods:{
       href_mx:function(id){
         this.$router.push({ name: 'withdrawalstate',query:{rewardId:id}})
       },
      list(){
        let vm = this;
        let flag = this.page>1;
        let apiurl = 0 == this.balanceType ?"/api/wap/accounts/moneyProfit?isAccountEntry="+this.isAccountEntry : "/api/wap/company/profit";
        apiurl = this.APIURL_PREFIX+ apiurl;
        this.$http.get(apiurl,{params:{page:this.page,rows:this.pageSize}}).then((response) => {
          let arRes = response.data.data;
          if(1== this.balanceType){
            console.log( 'shi1')
            arRes = arRes.map(function(item,i,ar){
              item.userBalance = item.companyBalance;
              item.userProfit = item.companyProfit;
              return item;
            })
          }
          if(flag){
                    this.shouyi_data = this.shouyi_data.concat(arRes);
                }else{
                  this.shouyi_data = arRes;
                }
                if( 0 == arRes.length || arRes.length<this.pageSize ){
                    this.busy = true;
                    this.loadall = true;
                }
                else{
                    this.busy = false;
                    this.page++
                }
        }).catch(function(err){
          console.log(err)
        });
        
      },

      loadMore(){
        this.busy = true;
        setTimeout(() => {
          this.list();
        }, 500);
      },

    }
}
</script>
<style scoped>
.sc{
  overflow: scroll; height: 100%;
}
.list li{
  height: 65px;
  border-bottom: 0.5px solid #e5e5e5;
  background: #ffffff;
  padding: 5px;
  overflow: hidden;
}

.list_left h1,.list_right h1{
  font-size: 15px;
  text-align: left;
  padding: 8px;
}
.list_right{
  float: right;
}
.list_right h1:nth-of-type(2){
  font-size: 12px;
  text-align: right;
}
.list_right h1:nth-of-type(1){
  text-align: right;
}
.lhd{
  height: 40px !important;
  line-height: 25px;
}





.TiTlelef{
    background: #feba01;
    color: #ffffff;
    padding: 8px;
    border-radius: 50%;
    margin-right: 10px;
  }
  .list_leftH{
    padding-top: 8px;
  }
.list li{
  height: 65px;
  border-bottom: 0.5px solid #e5e5e5;
  background: #ffffff;
  padding: 5px;
}
.list_left{
  float: left;
}



</style>


